TMP		=	./tmp
BIN_EXT	=	./bin-ext
BIN		=	./war/WEB-INF/classes
WAR		=	./war
DAEMON	=	autotc
CLIENT	=	autotc-client
WEBAPP	=	autotc

TARGET	=	./

DELSVN	=	find ./ -name ".svn" | xargs rm -Rf

all: help

help:
	@echo ""
	@echo "Use:"
	@echo "make daemon [TARGET=_target_folder_]"
	@echo ""

daemon:
	# Creating temporary folder
	mkdir -p $(TMP)
	
	# Copying files
	cp -f -R $(BIN_EXT)/* $(TMP)
	cp -f -R $(BIN)/* $(TMP)
	cp -f -R $(WAR) $(TMP)
	
	# renamed /war to /root
	mv -f $(TMP)/$(WAR) $(TMP)/./root
	
	# Deleting .svn folders
	find $(TMP) -name ".svn" | grep $(TMP)* | xargs rm -Rf
	
	# remove README
	rm $(TMP)/README
	
	# Creating $(DAEMON).jar
	rm -R $(TMP)/inglar/autotc/AutoTC.gwt.xml
	rm -R $(TMP)/inglar/autotc/client
	jar -cfm $(TARGET)/$(DAEMON).jar $(DAEMON).mf -C $(TMP)/ .
	
	# Creating $(CLIENT).jar
	
	# removing unused packages
	rm -R $(TMP)/com
	rm -R $(TMP)/org/gjt
	rm -R $(TMP)/org/mortbay
	rm -R $(TMP)/org/apache/jasper
	rm -R $(TMP)/org/apache/commons/logging
	rm -R $(TMP)/javax
	
	# remove /root
	rm -R $(TMP)/root
	
	jar -cfm $(TARGET)/$(CLIENT).jar $(CLIENT).mf -C $(TMP)/ .
	
	# Deleting temporary folder
	rm -R $(TMP)
	
	# Copying cfg files
	cp -f *.cfg $(TARGET)/

